tests: Remove gdk_draw_pixbuf() with Cairo equivalent
authorBenjamin Otte <otte@redhat.com>
Mon, 12 Jul 2010 13:45:12 +0000 (15:45 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Jul 2010 14:42:47 +0000 (16:42 +0200)
tests/testgtk.c
tests/testrgb.c

index c38c6d45ed3cdabcb880e72fa0b67cc49933d68c..47da56870163008ee67242ed9836ba5ed733b8d9 100644 (file)
@@ -256,6 +256,7 @@ on_alpha_drawing_expose (GtkWidget      *widget,
   int width = widget->allocation.width;
   int height = widget->allocation.height;
   GdkPixbuf *pixbuf;
+  cairo_t *cr;
   guchar *buffer;
   guchar *p;
   int i, j;
@@ -283,11 +284,15 @@ on_alpha_drawing_expose (GtkWidget      *widget,
 
   pixbuf = gdk_pixbuf_new_from_data (buffer, GDK_COLORSPACE_RGB, TRUE,
                                     8, 64, 64, 4 * 64, NULL, NULL);
+  cr = gdk_cairo_create (widget->window);
 
-  gdk_draw_pixbuf (widget->window, widget->style->black_gc, pixbuf,
-                  0, 0, x + width - 18 - 64, y + (height - 64) /2,
-                  64, 64, GDK_RGB_DITHER_NORMAL, 0, 0);
+  gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+  cairo_rectangle (cr,
+                   x + width - 18 - 64, y + (height - 64) /2,
+                   64, 64);
+  cairo_fill (cr);
 
+  cairo_destroy (cr);
   g_object_unref (pixbuf);
 
   g_free (buffer);
@@ -2755,14 +2760,17 @@ on_rotated_text_expose (GtkWidget      *widget,
       if (tile_pixbuf)
        {
          GdkPixmap *tile;
+          cairo_t *cr;
          
          gint width = gdk_pixbuf_get_width (tile_pixbuf);
          gint height = gdk_pixbuf_get_height (tile_pixbuf);
          
          tile = gdk_pixmap_new (widget->window, width, height, -1);
-         gdk_draw_pixbuf (tile, gc, tile_pixbuf,
-                          0, 0, 0, 0, width, height,
-                          GDK_RGB_DITHER_NORMAL, 0, 0);
+
+          cr = gdk_cairo_create (tile);
+          gdk_cairo_set_source_pixbuf (cr, tile_pixbuf, 0, 0);
+          cairo_paint (cr);
+          cairo_destroy (cr);
 
          gdk_gc_set_tile (gc, tile);
          gdk_gc_set_fill (gc, GDK_TILED);
index f4fdbc2cffcb924e0c6c9f41df16132a0f9fa003..b05018359dd6b9e3ce93f62ba264ce6d43e7e79a 100644 (file)
@@ -147,15 +147,17 @@ testrgb_rgb_test (GtkWidget *drawing_area)
       start_time = g_timer_elapsed (timer, NULL);
       for (i = 0; i < NUM_ITERS; i++)
        {
+          cairo_t *cr;
+
          offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
          pixbuf = gdk_pixbuf_new_from_data (buf + offset, GDK_COLORSPACE_RGB, TRUE,
                                             8, WIDTH, HEIGHT, WIDTH * 4,
                                             NULL, NULL);
-         gdk_draw_pixbuf (drawing_area->window, drawing_area->style->black_gc,
-                          pixbuf,
-                          0, 0, 0, 0, WIDTH, HEIGHT,
-                          GDK_RGB_DITHER_NORMAL,
-                          0, 0);
+          cr = gdk_cairo_create (drawing_area->window);
+          gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+          cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
+          cairo_fill (cr);
+          cairo_destroy (cr);
          g_object_unref (pixbuf);
        }
       gdk_flush ();